/* MACHINE-GENERATED ! */

frame pads {
	loop pin = first_pin, first_pin+pins_per_row-1

	__0: vec @(shift_x, dir*row_y)
	__1: vec .(dir*P*(pins_per_row-pin), 0mm)
	__2: vec .(-pad_width/2, -pad_length/2)
	__3: vec __1(pad_width/2, pad_length/2)
	pad "$pin" __2 .
}

frame holes {
	set d = 1.3mm

	__0: vec @(dir*F/2, 0mm)
	__1: vec .(-d/2, -d/2)
	__2: vec __0(d/2, d/2)
	hole __1 .
}

frame lateral_pad {
	set w = 1.3mm

	set l = 3.4mm

	__0: vec @(dir*(F/2+w), 0mm)
	__1: vec .(-w/2, -l/2)
	__2: vec __0(w/2, l/2)
	pad "$name" __1 .
}

frame silk {
	set W = 4.2mm

	set w = 2.9mm

	__0: vec @(-B/2, -W/2)
	__1: vec @(B/2, W/2)
	rect __0 . 0.1mm
	__2: vec @(dir*B/2, w/2)
	__3: vec @(dir*A/2, -w/2)
	rect . __2 0.1mm
}

package "DF9-$pins-1V"
unit mm
allow overlap
allow holes

table
    { pins, A, B, C, D, E, F, h }
    { 9, 10.1mm, 8.3mm, 6.5mm, 3mm, 4mm, 7.1mm, 1.84mm }
    { 11, 11.1mm, 9.3mm, 7.5mm, 4mm, 5mm, 8.1mm, 1.84mm }
    { 13, 12.1mm, 10.3mm, 8.5mm, 5mm, 6mm, 9.1mm, 1.84mm }
    { 15, 13.1mm, 11.3mm, 9.5mm, 6mm, 7mm, 10.1mm, 1.84mm }
    { 17, 14.1mm, 12.3mm, 10.5mm, 7mm, 8mm, 11.1mm, 1.84mm }
    { 19, 15.1mm, 13.3mm, 11.5mm, 8mm, 9mm, 12.1mm, 1.84mm }
    { 21, 16.1mm, 14.3mm, 12.5mm, 9mm, 10mm, 13.1mm, 1.84mm }
    { 23, 17.1mm, 15.3mm, 13.5mm, 10mm, 11mm, 14.1mm, 1.84mm }
    { 25, 18.1mm, 16.3mm, 14.5mm, 11mm, 12mm, 15.1mm, 1.84mm }
    { 31, 21.1mm, 19.3mm, 17.5mm, 14mm, 15mm, 18.1mm, 3mm }
    { 41, 26.1mm, 24.3mm, 22.5mm, 19mm, 20mm, 23.1mm, 3mm }

table
    { name, row_y, dir, pins_per_row, first_pin, shift_x }
    { "S1", (h+pad_length)/2, -1, (pins+1)/2, 1, 0mm }
    { "S2", (h+pad_length)/2, 1, (pins-1)/2, (pins+1)/2+1, 1.5*P }

set H = 6mm

set pad_length = (H-h)/2

set pad_width = 0.7mm

set P = 1mm

__0: vec @((pins-1)*P/4, 0mm)
frame pads .
frame holes @
frame lateral_pad @
frame silk @
